<?php
	$all_selection = substr($_POST['tdm_selected'],0,strlen($_POST['tdm_selected'])-1);
	if($all_selection ==''){die('<div class=Error>Nada para Validar.</div>');}
	$prStr = '<div id=printTdm name=printTdm style="margin-bottom:20px;height:500px;display:none">
	<div style="margin:3px;padding:3px;background-color:#CFCFCF"><b>Tuga Report - Serviço de Transferencias - Transmissoes de Dominio</b><br>Validado a: '.$sysTime.'<br>Validado por: <b>'.$_SESSION[$SESSID].'</b>
	</div><table style="width:100%">';
	$GET = $GLOBALS['MYT']->db_array("SELECT 
		`tdm_ID`,`tdm_Date`,`tdm_DateValue`, `tdm_TFraSent`,`tdm_InvTotal`,`tdm_TFraPay`,`dom_RazonSocial`,CorrNombre,pai_NombreUSD,cvt_Name,tdm_Currency,username,tdm_StartEnd,smb_CttEmail,tdm_Description
  				FROM `transmitionsdomain`
			INNER JOIN `dominios` ON `dom_ID` = (SELECT `OriDominio` FROM `origenes` WHERE `OriNumero` = tdm_Domain)
			LEFT OUTER JOIN `corresponsales` ON `CorrNumero` = `tdm_Corresponsal`
			LEFT OUTER JOIN hd_paises ON pai_CodElite = tdm_Country
			LEFT OUTER JOIN hd_cashiertypes ON cvt_ID = tdm_Cashier
			LEFT OUTER JOIN systemoffice.main_users ON ref = tdm_User
			LEFT OUTER JOIN systemoffice.staff_members ON smb_ID = StaffMember
			WHERE tdm_ID IN ({$all_selection})
			AND tdm_Flag IN (2)");

	$CGET = $GET[0];
		$TTotal = 0;
		$TSent = 0;
		$TPay = 0;

	for($i=1;$i<=$CGET;$i++){
		$TTotal += $GET[$i]['tdm_InvTotal'];
		$TSent += $GET[$i]['tdm_TFraSent'];
		$TPay += $GET[$i]['tdm_TFraPay'];

		$prStr .= '<tr><td colspan="10"><hr style="width:100%;size:1" /></td>
			<tr><td colspan="3">Dominio: <b>'.$GET[$i]['dom_RazonSocial'].'</b></td><td colspan="3">Data da comunicacao: '.$GET[$i]['tdm_Date'].', por: '.$GET[$i]['username'].'</td></tr>
			<tr><td colspan="7">Observ: '.$GET[$i]['tdm_Description'].'</td></tr>
			<tr><td>Remessas</td><td>Primeira e Ultima</td><td>Enviado</td><td>A Pagar</td><td>Correspondente</td><td>Pais</td><td>Caixa</td></tr>
			<tr><td>'.$GET[$i]['tdm_InvTotal'].'</td><td>'.$GET[$i]['tdm_StartEnd'].'</td><td>'.number_format($GET[$i]['tdm_TFraSent'],2,',','.').'</td><td>'.number_format($GET[$i]['tdm_TFraPay'],2,',','.').'</td><td>'.$GET[$i]['CorrNombre'].'</td><td>'.$GET[$i]['pai_NombreUSD'].'</td><td>'.$GET[$i]['cvt_Name'].'</td></tr>';
	}
		$prStr .= '<tr><td colspan="10"><hr style="width:100%;size:1" /></td>
			<tr><td colspan="3"></td><td colspan="3"></td></tr>
			<tr><td colspan="7"></td></tr>
			<tr><td>Remessas</td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
			<tr><td># '.$TTotal.'</td><td></td><td>Total Enviado: '.number_format($TSent,2,',','.').'</td><td>Total Pagar: '.number_format($TPay,2,',','.').'</td><td></td><td></td><td></td></tr>';

	$prStr .= '</table></div>
	<script charset="utf-8" type="text/javascript">printdiv(\'printTdm\');</script>';
	echo $prStr;
